using System.Reflection.Metadata.Ecma335;
using System.Threading.Tasks;
using JoyfulHomeJourney.BackEnd.Infrastructure.Dtos.Requests.Objects;
using JoyfulHomeJourney.BackEnd.Server.Interfaces;
using Microsoft.AspNetCore.Authorization;
using Microsoft.AspNetCore.Mvc;
namespace JoyfulHomeJourney.BackEnd.Api.Admin.Controllers
{
	[TypeFilter(typeof(CheckLoginFilter), Arguments = new object[] { new string[] { "admin","carShop" } })]
	public class SysCarServicesController : BaseController
	{
		private readonly ISysCarServicesServer _sysCarServicesServer;
		public SysCarServicesController(ISysCarServicesServer sysCarServicesServer)
		{
			_sysCarServicesServer = sysCarServicesServer;
		}
		/// <summary>
		/// 添加
		/// </summary>
		/// <param name="dto"></param>
		/// <returns></returns>
		[HttpPost]
		public async Task<IActionResult> Add([FromForm]RequestSysCarServicesDto dto)
		{
			return Send(await _sysCarServicesServer.AddAsync(dto));
		}
        /// <summary>
        /// 不带文件的添加
        /// </summary>
        /// <param name="dto"></param>
        /// <returns></returns>
        [HttpPost]
        public async Task<IActionResult> Add2(RequestSysCarServicesDto dto)
        {
            return Send(await _sysCarServicesServer.AddAsync2(dto));
        }
        /// <summary>
        /// 删除
        /// </summary>
        /// <param name="dto"></param>
        /// <returns></returns>
        [HttpPost]
		public async Task<IActionResult> Delete(RequestSysCarServicesDto dto)
		{
			return Send(await _sysCarServicesServer.DeleteAsync(dto));
		}
		/// <summary>
		/// 修改
		/// </summary>
		/// <param name="dto"></param>
		/// <returns></returns>
		[HttpPost]
		public async Task<IActionResult> Update([FromForm]RequestSysCarServicesDto dto)
		{
			return Send(await _sysCarServicesServer.UpdateAsync(dto));
		}
		/// <summary>
		/// 详情
		/// </summary>
		/// <param name="id"></param>
		/// <returns></returns>
		[HttpGet]
		public async Task<IActionResult> Detail(string id)
		{
			return Send(await _sysCarServicesServer.Detail(id));
		}
		/// <summary>
		/// 分页
		/// </summary>
		/// <param name="page"></param>
		/// <param name="limit"></param>
		/// <returns></returns>
		[HttpGet]
		public async Task<IActionResult> Pagination(int page, int limit, string key,string shopId, string field, bool? order)
		{
			return Send(await _sysCarServicesServer.PaginationAsync(page,limit,key,shopId,field,order));
		}
	}
}
